package cn.cdeden.aiqa.controller.llmApp;

import cn.cdeden.aiqa.domain.bo.Message;
import cn.cdeden.aiqa.domain.bo.OllamChatParam;
import cn.cdeden.aiqa.service.OllamaService;
import cn.cdeden.common.web.core.BaseController;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.List;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/ollama")
public class OllamaController extends BaseController {

    private final OllamaService ollamaService;

    /**
     * Ollama问答
     */
    @PostMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> chat(@RequestBody OllamChatParam param) {
        return ollamaService.chatWithOllama(param.getUrl(), param.getModel(), param.getMessage());
    }

}
